﻿//********************************************************************************//
//创建日期：<创建日期，2016-09-19>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：收费管理 生成本月托收
//********************************************************************************//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using System.Data;
using Platform.Http;
using System.Text;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS._5.ShouFeiGL
{
    public partial class ShengChengBYTS : System.Web.UI.Page
    {

       
         #region 属性

        #endregion

        #region 变量
        /// <summary>
        /// 存储过程执行类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();

        /// <summary>
        /// 操作日志BLL
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();

        /// <summary>
        /// 参数bll
        /// </summary>
        QS_CANSHUBBLL _CANSHUBLL = new QS_CANSHUBBLL();
        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }

        }

        /// <summary>
        /// 绑定空表头
        /// </summary>
        protected override void Render(HtmlTextWriter sender)
        {
            base.Render(sender);
        }

       

        /// <summary>
        /// 放弃
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            InitData();
        }
        /// <summary>
        /// 生成本月托收
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSCBYTS_Click(object sender, EventArgs e)
        {
            string result = "";
            int year = Convert.ToInt32(txtV.Text.Substring(0, 4));
            int month = Convert.ToInt32(txtV.Text.Substring(4, 2));
            _SpHelper.P_QSSF_TUOSHOUYZ(1, year, month, out result);
            if (Convert.ToInt32(result) > 0)
            {
                PageTools.AlertMsg(this, "托收信息已经送到银行,不允许提交");
                return;
            }
            else
            {
                _SpHelper.P_QSSF_TUOSHOUYZ(2, year, month, out result);
                if (Convert.ToInt32(result) > 0)
                {
                    PageTools.AlertMsg(this, "已经有到帐的信息,不允许生成本月托收");
                    return;
                }
                else
                {
                    //生成本月托收
                    //_SpHelper.P_QSSF_BENYUETS(2, year, month, null);

                }
            }

        }

        /// <summary>
        /// 提交数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnTiJao_Click(object sender, EventArgs e)
        {
            string result = "";
            int year = Convert.ToInt32(txtV.Text.Substring(0, 4));
            int month = Convert.ToInt32(txtV.Text.Substring(4, 2));
            _SpHelper.P_QSSF_TUOSHOUYZ(1, year, month, out result);
            if (Convert.ToInt32(result) > 0)
            {
                PageTools.AlertMsg(this, "托收信息已经送到银行,不允许提交");
                return;
            }
            else
            {
                _SpHelper.P_QSSF_TUOSHOUYZ(2, year, month, out result);
                if (Convert.ToInt32(result) > 0)
                {
                    PageTools.AlertMsg(this, "已经有到帐的信息,不允许生成本月托收");
                    return;
                }
                else
                {
                    //执行存储过程  银行批量代理上传接口
                    PageTools.AlertMsg(this, "提交成功！");
                }
            }
        }

        /// <summary>
        /// 响应前台回调
        /// </summary>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            //int id = Convert.ToInt32(this.hdCollection.Get("ID"));
            int year = Convert.ToInt32(txtV.Text.Trim());
            string msg = "";
            if (e.Parameter == "yz1")
            {
                DataTable dt = null;// _CGJHBLL.SelectQS_JH_NIANJIHsDynamic(string.Format("I_Y={0} and i_jlzt=0", txtV.Text.Trim()), null);
                if (dt.Rows.Count > 0)
                {
                    msg = "true";
                }
                else
                {
                    msg = "false";
                }
                e.Result = e.Parameter + "|0|" + msg;
            }
            else if (e.Parameter == "yz2")
            {
                //根据sname 是否 采灌井，以及年份来判断是否用户都已经制定计划
                string result = "";
                _SpHelper.P_QSJH_JIHUAGLXD("采灌井", year.ToString(), out result);
                msg = result == "0" ? "true" : "false";
                e.Result = e.Parameter + "|0|" + msg;
            }
            else if (e.Parameter == "xdjh")
            {
                //下达采灌计划
                _SpHelper.P_QSJH_XIADAJH(1,year, out msg);//1 下达成功
                e.Result = e.Parameter + "|0|" + msg;
            }

        }
        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            int wtype = BusinessTool.WType;
            txtV.Text = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();
        }
        #endregion        

      
    
    }
}